1845B - Come Together - CodeForces Solution


geometry implementation math

Please click on ads to support us..

C++ Code:

// COPYRIIGHT
// @SHARMA JI KA LADKA

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
ll m = 1e9 + 7;

// AB NAHI HO PA RHA  HAI VRO

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        ll ans = 1;
        ll d1 = x2 - x1;
        ll d2 = x3 - x1;
        ll d3 = y2 - y1;
        ll d4 = y3 - y1;
        if (d1 * d2 > 0)
        {

            ans += min(abs(d1), abs(d2));
        }
        if (d3 * d4 > 0)
        {
            ans += min(abs(d3), abs(d4));
        }
        cout << ans << endl;
    }
}


Comments

Submit
0 Comments
More Questions

1133A - Middle of the Contest
385A - Bear and Raspberry
1311B - WeirdSort
1713F - Lost Array
236B - Easy Number Challenge
275A - Lights Out
147A - Punctuation
253A - Boys and Girls
1327E - Count The Blocks
984A - Game
12B - Correct Solution
1355B - Young Explorers
485A - Factory
628A - Tennis Tournament
1436B - Prime Square
1707B - Difference Array
1422C - Bargain
1611F - ATM and Students
660A - Co-prime Array
1692F - 3SUM
1470A - Strange Birthday Party
190D - Non-Secret Cypher
1721B - Deadly Laser
1721C - Min-Max Array Transformation
1721A - Image
1180C - Valeriy and Deque
557A - Ilya and Diplomas
1037D - Valid BFS
1144F - Graph Without Long Directed Paths
1228A - Distinct Digits